
#include<math.h>


double sq(double x){return x*x;}


double integrate(double a,double b,double(*f)(double)){
    int N=1000;
    double dx=(b-a)/N;
    int i;
    double s=0;
    for(i=0;i<N;i++)
        s+=f(a+i*dx)*dx;
    return s;
}


int main()
{
    printf("%.6f\n",integrate(0,1,sq));
    printf("%.6f\n",integrate(0,1,sin));
    printf("%.6f\n",integrate(0,1,cos));
    return 0;
}
